<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function getType(value) {
        return Object.prototype.toString
          .call(value) // [object Undefined]
          .match(/\s+(\w+)/)[1] // Undefined
          .toLowerCase() // undefined
      }
      console.log(getType('')) // string
      console.log(getType(2)) // number
      console.log(getType(true)) // boolean
      console.log(getType(undefined)) // undefined
      console.log(getType(null)) // null
      console.log(getType(Symbol())) // symbol
      console.log(getType({})) // object
      console.log(getType([])) // array
      console.log(getType(alert)) // function
      console.log(getType(new RegExp())) // regExp
      console.log(getType(new Date())) // date
    </script>
  </body>
</html>
